package consts

const (
	MyOpenApiUITemplate = `
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1" />
	<meta name="description" content="OpenAPI UI">
	<title>SwaggerUI</title>
	<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.10.5/swagger-ui.min.css" />-->
	<!--<link rel="stylesheet" href="https://cdn.staticfile.org/swagger-ui/4.15.5/swagger-ui.min.css" />
	<link rel="stylesheet" href="/assets/swagger/swagger-ui.css" />-->
	<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/redoc-try-it-out/dist/try-it-out.min.js"></script>
</head>
<body>
	<div id="redoc_container"></div>
	<script>
    	RedocTryItOut.init(
			"./api.json",
			{ title: "Cwt gf", authBth: {text: 'AUTHORIZE'} }, 
			document.getElementById("redoc_container")
    	)
		
		setTimeout(function () {
			addAuthButton();
		}, 1000); // 延迟1秒

		function addAuthButton() {
			var div = document.createElement('div')
			var button = document.createElement('button')
			button.appendChild(document.createTextNode('Authorization'))
			button.style = 'position: fixed; left: 50px; top:150px; font-size: 14px; font-weight: 700; min-width: 80px; padding: 6px 15px; text-align: center; border-radius: 3px; background: #41cd8e; text-shadow: 0 1px 0 rgba(0,0,0,.1); font-family: Titillium Web,sans-serif; color: #fff; border: none;'
			button.addEventListener('click', function(event) {
			event.preventDefault()
			var token = prompt('Enter JWT access token token. Eg. eyJraW...qJSaxQ. Note: do not need to put Bearer in the beginning')
			if (!token) {
			  // localStorage.removeItem('accessToken')
			  // alert('Token cleared')
			} else {
				var accessToken = token
				var bearer = token.indexOf('Bearer ') == 0
				if (bearer) {
					token = token.substring(7)
				}
	
				token = token.replace(/[^\d\w_.-]/gi, '')
	
				if (bearer) {
					accessToken = 'Bearer ' + token
				}
	
				localStorage.setItem('accessToken', accessToken)
			}
	  	})
	
	  var container = document.querySelector('.api-content')
	  container.appendChild(div.appendChild(button))
	}
	</script>
</body>
`
)
